<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title" id="ntModalLabel">{:lang('add/change_country')}</h4>
</div>
<form class="modal-body formbox">
        <div class="row clearfix">
                <div class="col-md-12 column">
                    <div class="alert alert-dismissable alert-info">
                        <button type="button" class="close">×</button>
                         <p></p>
                    </div>
                </div>
            </div>
    <table class="table table-striped table-hover ntTable">
        <tbody>
        <tr>
            <td>{:lang('country_name')}<span class="required"></span></td>
            <td><input type="text" class="form-control" name="name" placeholder="{:lang('country_name')}" value="{$info.name|default=''}">
            </td>
        </tr>
        <tr>
            <td>{:lang('phone_area_code')}<span class="required"></span></td>
            <td>
                <input type="text" class="form-control" name="tel" placeholder="{:lang('phone_area_code')}" value="{$info.tel|default=''}">
            </td>
        </tr>
        <tr>
            <td>{:lang('abbreviation')}<span class="required"></span></td>
            <td>
                <input type="text" class="form-control" name="short_name" placeholder="{:lang('abbreviation')}"
                       value="{$info.short_name|default=''}">
            </td>
        </tr>
        <tr>
            <td>{:lang('currency_unit')}<span class="required"></span></td>
            <td>
                <input type="text" class="form-control" name="currncy" placeholder="{:lang('currency_unit')}"
                       value="{$info.currncy|default=''}">
            </td>
        </tr>
        </tbody>
    </table>
    <input type="hidden" id="act" name="act" value="{$str}">
    <input type="hidden" name="id" id="id" value="{$info.id|default=''}">
</form>
<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span>{:lang('cancel')}
    </button>
    <button type="button" id="quedin" class="btn btn-primary" style="padding-left:24px;padding-right:24px">
        <span class="glyphicon glyphicon-floppy-save"></span>{:lang('save_and_exit')}
    </button>
    {if ($str eq 'countryadd')}
    <button type="button" id="qudins" class="btn btn-primary" style="padding-left:24px;padding-right:24px">
        <span class="glyphicon glyphicon-floppy-disk"></span>{:lang('save_and_continue_adding')}
    </button>
    {/if}
</div>
<script>
    //数据的提交,保存并退出
    $('#quedin').click(function () {
        subfn(1)
    });
    //保存并继续添加
    $('#qudins').click(function () {
        subfn(2)
    })
    var addbm = true;
    function subfn(code) {
        if (addbm) {
            $.ajax({
                url: '/Admin/prefecture/' + $('#act').val(),
                type: 'post',
                data: $(".formbox").serialize(),
                dataType: 'json',
                success: function (res) {
                    if (res.status != 1) {
                        change_mes_type('.modal-body .alert',res.status)
                        $('.modal-body .alert').show()
                        $('.modal-body .alert p').html('*'+res.msg+'<br>')
                        //toastr.warning(res.msg)
                    } else {
                        change_mes_type('.alert',res.status)
                        if (code == 1) {
                            addbm = false
                            //toastr.info(res.msg)
                            $('.alert').show()
                            $('.alert p').html('*'+res.msg+'<br>')
                            $('#country_editModal').modal('hide')
                            /* setTimeout(function () {
                                $('#country_editModal').modal('toggle')
                            }, 1000) */
                        } else {
                            $('.alert').show()
                            $('.alert p').html('*'+res.msg+'<br>')
                            //toastr.info(res.msg);
                        }

                    }
                }
            });
        }
    }
    //渲染所属部门的数据
    $(document).keydown(function (event) {
        if (event.keyCode == 13) {
            $('form').each(function () {
                event.preventDefault();
            });
            subfn(1)
        }
    });
</script>